<?php

/**
 * This is the model class for table "cs_xc_importinfo".
 *
 * The followings are the available columns in table 'cs_xc_importinfo':
 * @property integer $id
 * @property integer $approvaltrans_id
 * @property string $cWaterNo
 * @property string $policyNum
 * @property string $policyStatus
 * @property string $realDate
 * @property string $retCode
 * @property string $retDesc
 * @property string $startDate
 * @property string $endDate
 * @property string $strLockKey
 * @property integer $hashCodeCalc
 * @property integer $createTime
 * @property string $in_company
 * @property string $orderNo
 * @property integer $is_subscribed
 * @property integer $is_send
 * @property string $epolicyAddress
 */
class Db2CsXcImportinfo extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'cs_xc_importinfo';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('approvaltrans_id, hashCodeCalc, createTime, is_subscribed, is_send', 'numerical', 'integerOnly'=>true),
			array('cWaterNo, policyNum, policyStatus, realDate, retCode, retDesc, startDate, endDate', 'length', 'max'=>40),
			array('strLockKey', 'length', 'max'=>200),
			array('in_company, orderNo', 'length', 'max'=>45),
			array('epolicyAddress', 'length', 'max'=>500),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, approvaltrans_id, cWaterNo, policyNum, policyStatus, realDate, retCode, retDesc, startDate, endDate, strLockKey, hashCodeCalc, createTime, in_company, orderNo, is_subscribed, is_send, epolicyAddress', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'approvaltrans_id' => 'Approvaltrans',
			'cWaterNo' => 'C Water No',
			'policyNum' => 'Policy Num',
			'policyStatus' => 'Policy Status',
			'realDate' => 'Real Date',
			'retCode' => 'Ret Code',
			'retDesc' => 'Ret Desc',
			'startDate' => 'Start Date',
			'endDate' => 'End Date',
			'strLockKey' => 'Str Lock Key',
			'hashCodeCalc' => 'Hash Code Calc',
			'createTime' => 'Create Time',
			'in_company' => 'In Company',
			'orderNo' => 'Order No',
			'is_subscribed' => 'Is Subscribed',
			'is_send' => 'Is Send',
			'epolicyAddress' => 'Epolicy Address',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('approvaltrans_id',$this->approvaltrans_id);
		$criteria->compare('cWaterNo',$this->cWaterNo,true);
		$criteria->compare('policyNum',$this->policyNum,true);
		$criteria->compare('policyStatus',$this->policyStatus,true);
		$criteria->compare('realDate',$this->realDate,true);
		$criteria->compare('retCode',$this->retCode,true);
		$criteria->compare('retDesc',$this->retDesc,true);
		$criteria->compare('startDate',$this->startDate,true);
		$criteria->compare('endDate',$this->endDate,true);
		$criteria->compare('strLockKey',$this->strLockKey,true);
		$criteria->compare('hashCodeCalc',$this->hashCodeCalc);
		$criteria->compare('createTime',$this->createTime);
		$criteria->compare('in_company',$this->in_company,true);
		$criteria->compare('orderNo',$this->orderNo,true);
		$criteria->compare('is_subscribed',$this->is_subscribed);
		$criteria->compare('is_send',$this->is_send);
		$criteria->compare('epolicyAddress',$this->epolicyAddress,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * @return CDbConnection the database connection used for this class
	 */
	public function getDbConnection()
	{
		return Yii::app()->db2;
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Db2CsXcImportinfo the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
